/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package database.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Stefan
 */
@Entity
@Table(name = "item_group")
@NamedQueries({
    @NamedQuery(name = "ItemGroup.findAll", query = "SELECT i FROM ItemGroup i"),
    @NamedQuery(name = "ItemGroup.findByItemgroupid", query = "SELECT i FROM ItemGroup i WHERE i.itemgroupid = :itemgroupid"),
    @NamedQuery(name = "ItemGroup.findByItemgroupname", query = "SELECT i FROM ItemGroup i WHERE i.itemgroupname = :itemgroupname"),
    @NamedQuery(name = "ItemGroup.findByItemgrouplevel", query = "SELECT i FROM ItemGroup i WHERE i.itemgrouplevel = :itemgrouplevel")})
public class ItemGroup implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ITEMGROUPID")
    private Integer itemgroupid;
    @Basic(optional = false)
    @Column(name = "ITEMGROUPNAME")
    private String itemgroupname;
    @Basic(optional = false)
    @Column(name = "ITEMGROUPLEVEL")
    private int itemgrouplevel;
    @ManyToMany(mappedBy = "itemGroupList", fetch = FetchType.LAZY)
    private List<ShopItem> shopItemList;
    @OneToMany(mappedBy = "itemGroup", fetch = FetchType.LAZY)
    private List<ItemGroup> itemGroupList;
    @JoinColumn(name = "ITEMGROUPPARENT", referencedColumnName = "ITEMGROUPID")
    @ManyToOne(fetch = FetchType.LAZY)
    private ItemGroup itemGroup;

    public ItemGroup() {
    }

    public ItemGroup(Integer itemgroupid) {
        this.itemgroupid = itemgroupid;
    }

    public ItemGroup(Integer itemgroupid, String itemgroupname, int itemgrouplevel) {
        this.itemgroupid = itemgroupid;
        this.itemgroupname = itemgroupname;
        this.itemgrouplevel = itemgrouplevel;
    }

    public Integer getItemgroupid() {
        return itemgroupid;
    }

    public void setItemgroupid(Integer itemgroupid) {
        this.itemgroupid = itemgroupid;
    }

    public String getItemgroupname() {
        return itemgroupname;
    }

    public void setItemgroupname(String itemgroupname) {
        this.itemgroupname = itemgroupname;
    }

    public int getItemgrouplevel() {
        return itemgrouplevel;
    }

    public void setItemgrouplevel(int itemgrouplevel) {
        this.itemgrouplevel = itemgrouplevel;
    }

    public List<ShopItem> getShopItemList() {
        return shopItemList;
    }

    public void setShopItemList(List<ShopItem> shopItemList) {
        this.shopItemList = shopItemList;
    }

    public List<ItemGroup> getItemGroupList() {
        return itemGroupList;
    }

    public void setItemGroupList(List<ItemGroup> itemGroupList) {
        this.itemGroupList = itemGroupList;
    }

    public ItemGroup getItemGroup() {
        return itemGroup;
    }

    public void setItemGroup(ItemGroup itemGroup) {
        this.itemGroup = itemGroup;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (itemgroupid != null ? itemgroupid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ItemGroup)) {
            return false;
        }
        ItemGroup other = (ItemGroup) object;
        if ((this.itemgroupid == null && other.itemgroupid != null) || (this.itemgroupid != null && !this.itemgroupid.equals(other.itemgroupid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "database.entity.ItemGroup[itemgroupid=" + itemgroupid + "]";
    }

}
